﻿CREATE PROCEDURE [dbo].[proc_Project_Task_Getlist_MyPro]
	(
		@ProjectId uniqueidentifier,
		@UserName nvarchar(50)
	)
AS
begin
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY IsFinish)AS Row
		,Id
		,TaskId
		,OrderId
		,ProjectId
		,CusName
		,Title
		,Description
		,DownPersonName
		,StartDate
		,ExecDepartmentId
		,ExecDepartmentName
		,ISNULL(EndDate,'1900-01-01') As EndDate
		,datediff(day,StartDate,ISNULL(EndDate,GetDate())) As CountDay
		,IsFinish
		,(Select Count(Id) From Project_Task p Where p.FId=Project_Task.TaskId) As ChildCount
		From Project_Task
		Where ProjectId=@ProjectId and DownPerson=@UserName
	)
	Select * From list
end
	RETURN
